﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "LearnProcess")]
    public class LearnProcessInfo : IDetach
    {
        public LearnProcessInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _studentid = 0;
        private string _learnsection = "";
        private DateTime _starttime = DateTime.Now;
        private DateTime _endtime = DateTime.Now;
        private int _questioncount = 0;
        private int _topiccount = 0;

        private int _sectioncount = 0;
        private string _lastsection = "";
        private int _learntime = 0;
        private EntityRef<StudentInfo> _studentInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_studentInfo", ThisKey = "StudentId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public StudentInfo StudentInfo
        {
            get { return _studentInfo.Entity; }
            set { _studentInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int StudentId
        {
            set { _studentid = value; }
            get { return _studentid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string LearnSection
        {
            set { _learnsection = value; }
            get { return _learnsection; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime StartTime
        {
            set { _starttime = value; }
            get { return _starttime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime EndTime
        {
            set { _endtime = value; }
            get { return _endtime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int QuestionCount
        {
            set { _questioncount = value; }
            get { return _questioncount; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int TopicCount
        {
            set { _topiccount = value; }
            get { return _topiccount; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int SectionCount
        {
            set { _sectioncount = value; }
            get { return _sectioncount; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string LastSection
        {
            set { _lastsection = value; }
            get { return _lastsection; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int LearnTime
        {
            set { _learntime = value; }
            get { return _learntime; }
        }
        #endregion Model

        public void Detach()
        {
            this._studentInfo = default(EntityRef<StudentInfo>);
        }
    }
}
